#include <stdio.h>

#include <gmp.h>
#include <mpfr.h>

int main (void)
{
  unsigned int i;
  mpfr_t s, t, u;
  long double f1 = 3.1234688642135797531L, f2 = 2.1357975312468864322L;

  printf ("Float product is %Lf\n", f1*f2);

  // mpfr_init2 (t, 200);
  mpfr_init_set_ld (t, f1, GMP_RNDD);
  mpfr_init_set_ld (s, f2, GMP_RNDD);

  mpfr_init2 (u, 100);
  int g = mpfr_mul(u, t, s, GMP_RNDU);

  printf ("Multiprecision product is ");
  mpfr_out_str(stdout, 10, 0, u, GMP_RNDD);
  printf ("\n %d \n", g);

  for (i = 1; i <= 0; i++)
    {
      mpfr_mul_ui (t, t, i, GMP_RNDU);
      mpfr_set_d (u, 1.0, GMP_RNDD);
      mpfr_div (u, u, t, GMP_RNDD);
      mpfr_add (s, s, u, GMP_RNDD);
    }
  printf ("Sum is ");
  mpfr_out_str (stdout, 10, 0, s, GMP_RNDD);
  putchar ('\n');
  mpfr_clear (s);
  mpfr_clear (t);
  mpfr_clear (u);
  return 0;
}
